package com.mmall.task;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RedisShardedPoolUtil {

    public static Long setnx(String key, String value){
        SharedJedis jedis = null;
        Long result = null;
        try{
            jedis = RedisShardedPool.getJedis();
            result = jedis.set(key, value);
        }catch (Exception e){
            log.error("set key:{} value:{} error", key, value, e);
            RedisShardedPool.returnBrokenResource(jedis);
            return result;
        }
        RedisShardedPool.returnResource(jedis);
        return result;
    }
}
